﻿Imports System.Data.OleDb
Public Class filmDetail
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim conn As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("godzillaFilms").ConnectionString)
        Dim sql = "SELECT * FROM AverageFilmRatings WHERE FilmID=@f1"
        Dim cmd As OleDbCommand = New OleDbCommand(sql, conn)
        conn.Open()
        cmd.Parameters.AddWithValue("@f1", Request.Params("ID"))
        cmd.ExecuteNonQuery()
        Dim dr As OleDbDataReader = cmd.ExecuteReader()
        dr.Read()
        If dr.HasRows() Then
            rating_average.CurrentRating = dr("AverageRating")
        End If
        conn.Close()

        Dim sqlView = "INSERT INTO FilmPageViews (FilmID, FanName) VALUES (@f1, @f2)"
        Dim cmdView As OleDbCommand = New OleDbCommand(sqlView, conn)
        conn.Open()
        cmdView.Parameters.AddWithValue("@f1", Request.Params("ID"))
        cmdView.Parameters.AddWithValue("@f2", User.Identity.Name)
        cmdView.ExecuteNonQuery()
        conn.Close()
    End Sub

End Class